# Definition for singly-linked list.
class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next


class Solution:
    def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
        value1, l1 = l1.val, l1.next
        value2, l2 = l2.val, l2.next
        value = (value1 + value2)//10
        dummy = ListNode((value1 + value2)%10)
        head = dummy
        while l1.next and l2.next:
            value1, l1 = l1.val, l1.next
            value2, l2 = l2.val, l2.next
            value, node = (value1 + value2 + value)//10, (value1 + value2 + value)%10
            dummy.next = ListNode(node)
            dummy = dummy.next
        while l1.next:
            value1, l1 = l1.val, l1.next
            value, node = (value1 + value)//10, (value1 + value)%10
            dummy.next = ListNode(node)
            dummy = dummy.next
        while l2.next:
            value2, l2 = l2.val, l2.next
            value, node = (value2 + value)//10, (value2 + value)%10
            dummy.next = ListNode(node)
            dummy = dummy.next
        return head

l1 = [2,4,3]
l2 = [5,6,4]
print(Solution().addTwoNumbers(l1, l2))